package com.yqz.bussi.service.impl;

import com.yqz.bussi.form.BussiBookingCustomerForm;
import com.yqz.bussi.mapper.BussiBookingCustomerMapper;
import com.yqz.bussi.service.BussiBookingCustomerService;
import com.yqz.bussi.vo.BussiBookingCustomerVO;
import com.yqz.common.Constant;
import com.yqz.common.Result;
import com.yqz.common.base.service.impl.BaseServiceImpl;
import com.yqz.common.validator.ValidatorUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BussiBookingCustomerServiceImpl extends BaseServiceImpl implements BussiBookingCustomerService {

    @Autowired
    private BussiBookingCustomerMapper bussiBookingCustomerMapper;

    public BussiBookingCustomerServiceImpl(BussiBookingCustomerMapper bussiBookingCustomerMapper) {
        super(bussiBookingCustomerMapper);
    }

    @Override
    public Result updateCustomerUser(List<Integer> custId, Integer userId, String userName) {
        bussiBookingCustomerMapper.batchUpdateUser(userId,userName,custId);
        return new Result();
    }

    @Override
    public Result usingCustomer(Integer id) {
        BussiBookingCustomerVO bussiBookingCustomerVO = bussiBookingCustomerMapper.selectByPrimaryKey(id);
        BussiBookingCustomerForm bussiBookingCustomerForm = new BussiBookingCustomerForm();
        BeanUtils.copyProperties(bussiBookingCustomerVO,bussiBookingCustomerForm);
        ValidatorUtil.validate(bussiBookingCustomerForm);
        bussiBookingCustomerMapper.updateState(Constant.CUSTOMER_STATE_VALID,id);
        return new Result();
    }

    @Override
    public void resetCheckFeeState() {
        bussiBookingCustomerMapper.resetCheckFeeState();
    }
}
